package com.qf.ssm.controller;


import com.github.pagehelper.PageInfo;
import com.qf.ssm.qo.CarDispatchQo;
import com.qf.ssm.qo.CarDispatchRecodeQo;
import com.qf.ssm.result.ResponseResult;
import com.qf.ssm.service.CarDispatchService;
import com.qf.ssm.vo.CarAndStoreInfoVo;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@Api(tags = "车辆调度接口")
@RequestMapping("/car/dispatch")
public class CarDispatchController {

    @Autowired
    private CarDispatchService carDispatchService;

    @PostMapping(path={"/list/{page}/{size}"})
    @ApiOperation("分页查询车辆以及相关门店信息")
    @ApiResponses({@ApiResponse(code = 2000, message = "成功", response =Integer.class), @ApiResponse(code = 4000, message = "未知错误)")})
    public ResponseResult<PageInfo<CarAndStoreInfoVo>> infoList(@ApiParam("页数") @PathVariable(value = "page",required = false)Integer page,
                                                                @ApiParam("条数") @PathVariable(value = "size",required = false)Integer size,
                                                               @RequestBody CarDispatchQo carDispatchQo){
         return ResponseResult.success(carDispatchService.infoList(page,size,carDispatchQo));
    }


    @PostMapping("/begin")
    @ApiOperation("开始派遣人员调度,并增加调度信息记录")
    @ApiResponses({@ApiResponse(code = 2000, message = "成功", response =Integer.class), @ApiResponse(code = 4000, message = "未知错误)")})
    public ResponseResult<Integer>CarDispatchBegin(@RequestBody CarDispatchRecodeQo carDispatchRecodeQo){
        return ResponseResult.success(carDispatchService.carDispatchBegin(carDispatchRecodeQo));
    }

    @PostMapping("/finish/{did}")
    @ApiOperation("调度完成,并记录调度完成的时间")
    @ApiResponses({@ApiResponse(code = 2000, message = "成功", response =Integer.class), @ApiResponse(code = 4000, message = "未知错误)")})
    public ResponseResult<Integer>carDispatchFinish(@PathVariable("did") Integer did){

        return ResponseResult.success(carDispatchService.carDispatchFinish(did));
    }
}
